class CreateGoods < ActiveRecord::Migration
  def self.up
    create_table :goods, :options => 'CHARSET=utf8, ENGINE=Innodb', :force => true do |t|
      t.column :name, :string, :null => false                             # 商品名称
      t.column :category_id, :integer, :null => false, :default => 0      # 分类id
      t.column :brand_id, :integer, :null => false, :default => 0         # 品牌id
      t.column :supplier_id, :integer, :default => 0                      # 供货商id
      t.column :type_id, :integer, :null => false, :default => 0          # 商品类型id
      t.column :code, :string                                             # 货号
      t.column :intro, :text                                              # 商品详情
      t.column :wholesale, :text                                          # 批发说明
      t.column :stock, :integer, :null => false, :default => 0            # 库存量
      t.column :price, :float, :null => false, :default => 0              # 商品价格
      t.column :member_price, :boolean, :null => false, :default => true  # 1为默认开启会员价格，0为不开启，开启时如果没有设置具体价格，会按照会员组折扣计算价格
      t.column :transport_price, :float, :null => false, :default => 0    # 运费
      t.column :weight, :float, :null => false, :default => 0             # 商品重量
      t.column :points, :integer, :null => false, :default => 0           # 购买商品时赠送的积分
      t.column :coins, :integer, :null => false, :default => 0            # 购买商品时赠送的商城币
      t.column :coin_purchase, :integer, :null => false, :default => 0    # 购买该商品时最多可以使用的商城币数量
      t.column :keyword, :string, :null => false, :default => 0           # 关键字
      t.column :best_goods, :boolean, :null => false, :default => false   # 1为精品
      t.column :new_goods, :boolean, :null => false, :default => false    # 1为新品
      t.column :hot_goods, :boolean, :null => false, :default => false    # 1为热销
      t.column :promote_goods, :boolean, :null => false, :default => false # 1为特价
      t.column :on_sale, :boolean, :null => false, :default => false       # 0为下架，1为上架
      t.column :set_image, :boolean, :null => false, :default => false     # 是否已设置图片
      t.column :thumb_image, :string, :null => false                      # 缩略图
      t.column :pv, :integer, :null => false, :default => 0               # 关注度
      t.column :favpv, :integer, :null => false, :default => 0            # 被收藏次数
      t.column :sort_order, :integer, :null => false, :default => 0       # 排序
      t.column :lock_flg, :boolean, :null => false, :default => false     # 锁定，1为锁定
      t.column :specification, :string                                    # 规格id,以逗号分割 
      t.column :deleted_at, :datetime                                     # 删除时间
      t.timestamps
    end
  end

  def self.down
    drop_table :goods
  end
end
